<?php /* Smarty version 2.6.14, created on 2014-12-15 14:01:52
         compiled from recommend.recommendlist.html */ ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "header.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<link href="<?php echo @BASEURI; ?>
public/css/jui/jui.css" type="text/css" rel="stylesheet" />
<script language="JavaScript" src="<?php echo @BASEURI; ?>
public/js/jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script>
<div>
    <h1><?php echo $this->_tpl_vars['systemLang']['top']; ?>
</h1>
    <dl id="top" style="padding:5px;">
        <?php $_from = $this->_tpl_vars['content']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['row']):
?>
        	<?php if ($this->_tpl_vars['row']['fistop'] == 1): ?>
	        <dd data-id="<?php echo $this->_tpl_vars['row']['fid']; ?>
" class="ui-state-default">
	        <table width="100%">
	            <tr>
	                <td width="30%"><img src="<?php echo @IMG_URL;  echo $this->_tpl_vars['row']['pic']; ?>
" /></td>
	                <td width="50%"><?php echo $this->_tpl_vars['row']['name']; ?>
</td>
	                <td width="20%">
			                    【<a onclick="deltop(<?php echo $this->_tpl_vars['row']['fid']; ?>
);"><?php echo $this->_tpl_vars['systemLang']['cancelTop']; ?>
</a>】
			                    【<a onclick="del(<?php echo $this->_tpl_vars['row']['fid']; ?>
)"><?php echo $this->_tpl_vars['systemLang']['cancelPush']; ?>
</a>】
	                </td>
	            </tr>
	        </table>
	        </dd>
        	<?php endif; ?>
        <?php endforeach; endif; unset($_from); ?>       
    </dl>
</div>
<div>
    <h1><?php echo $this->_tpl_vars['systemLang']['top']; ?>
</h1>
    <dl id="recommendlist" style="padding:5px;">
	   <?php $_from = $this->_tpl_vars['content']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['row']):
?>
	   		<?php if ($this->_tpl_vars['row']['fistop'] != 1): ?>
	       <dd data-id="<?php echo $this->_tpl_vars['row']['fid']; ?>
" class="ui-state-default">
	        <table width="100%">
	            <tr>
	                <td width="30%"><img src="<?php echo @IMG_URL;  echo $this->_tpl_vars['row']['pic']; ?>
" /></td>
	                <td width="50%"><?php echo $this->_tpl_vars['row']['name']; ?>
</td>
	                <td width="20%">
	                                        【<a onclick="addtop(<?php echo $this->_tpl_vars['row']['fid']; ?>
);"><?php echo $this->_tpl_vars['systemLang']['top']; ?>
</a>】
	                                        【<a onclick="del(<?php echo $this->_tpl_vars['row']['fid']; ?>
)"><?php echo $this->_tpl_vars['systemLang']['cancelPush']; ?>
</a>】
	                </td>
	            </tr>
	        </table>
	        </dd>
        	<?php endif; ?>
		<?php endforeach; endif; unset($_from); ?> 
    </dl>
</div>
<button style="margin:15px;" onclick="saveSort();"><?php echo $this->_tpl_vars['systemLang']['keepSort']; ?>
</button>
<script>
function saveSort(){
    var tops = $("#top dd");
    var list = $('#recommendlist dd');
    var parms = {top :{},'list':{}};
    for(var i = 0 ; i < tops.size();i++)
    {
        parms.top[$(tops[i]).attr('data-id')] = i;
    }
    for(var i = 0 ; i < list.size();i++)
    {
        parms.list[$(list[i]).attr('data-id')] = i;
    }
    $.post('/recommend/recommendsort',parms,function(r){
        window.location.reload();
    });
}
function addtop(fid){
    $.post("/recommend/recommendtop",{'fid' : fid},function(){
        window.location.reload();
    });
}
function deltop(fid){
    $.post("/recommend/recommendtopdel",{'fid' : fid},function(){
        window.location.reload();
    });
}
function del(fid){
    $.post("/recommend/recommenddel",{'fid' : fid},function(){
        $('dd[data-id="'+fid+'"]').remove();
    });
}
$(document).ready(function(){
    $( "#top,#recommendlist" ).sortable({
		revert: true
	});
});
</script>